<?php if ($this->st_registry->registry('admin/system/user/message')) : ?>
    <div class="stdWidth autoCenter message">
        <?php echo $this->st_registry->getFlashMessage('admin/system/user/message'); ?>
    </div>
<?php endif; ?>
<?php $pagData = $paginator->getPages('slider'); ?>
<?php echo form_open_multipart('admin/system/user/index', array('id' => 'frmUserGridView')); ?>
<?php echo fx_control::newInstance('formKey')->createType('hidden')->setData('value', random_string('unique', 16))->render(); ?>
<?php echo fx_control::newInstance('user_ids')->createType('hidden')->setData('value', $user_ids)->render(); ?>
    <input type="hidden" class="pageIndex" id="userPageIndex" value="<?php echo $paginator->getCurrentPageNumber() ?>" name="page"/>
    <div id="box">
        <div id="title">
            <h4><?php echo $module['title'] ?></h4>
        </div>
        <div id="toolBar">
            <ul>
                <li class="new"><a class="flashEditor" href="<?php echo site_url('admin/system/user/edit', true) ?>"><span>New</span></a></li>
                <li class="selectAll"><a href="#" onclick="return selectAll('chkUser', 'user_ids', '<?php echo site_url('admin/grid/select/user_model',true)?>', 'userItemSelected', 'userSelectedValueHidden')"><span>Select All</span></a></li>
                <li><a href="#" onclick="return unSelectAll('chkUser', 'user_ids', 'userItemSelected', 'userSelectedValueHidden')"><span>Unselect All</span></a></li>
                <li class="select"><a href="#" onclick="return selectVisible('chkUser', 'user_ids', 'userItemSelected', 'userSelectedValueHidden')"><span>Select Visible</span></a></li>
                <li class="first"><a href="#" onclick="return unSelectVisible('chkUser', 'user_ids', 'userItemSelected', 'userSelectedValueHidden')"><span>Unselect Visible</span></a></li>
            </ul>
        </div>
        <div id="informationTable">
            <div id="action">
                <input name="btnSubmit" type="submit" value="Search" class="btnBlue left"/>
                <input name="btnReset" type="button" value="Reset" class="btnBlue left btnReset" />
                <div id="selectAction" class="right">
                    <?php echo fx_control::newInstance('selectMassAction')
								 ->createType('option')
								 ->addOption('', '')
								 ->addOption('Active', site_url("admin/system/user/massActive", true))
								 ->addOption('Deactive', site_url("admin/system/user/massDeactive", true))
								 ->addClass('massSelectAction')
								 ->addClass('stdSelect')
								 ->render(); 
					?>
					<input type="button" class="btnBlue" id="btnActiveAction" value="Action" onclick="activeMassAction('frmUserGridView', 'selectMassAction')" />
                </div>
            </div>
            <div class="pagination">
                <div class="results">
                    <span>showing results <?php echo $pagData->firstItemNumber ?>-<?php echo $pagData->lastItemNumber ?> of <?php echo $found ?></span>
                </div>
                <div class="page">
                    <ul>
                        <?php if ($paginator->getCurrentPageNumber() <= 1) : ?>
                            <li><a>« Previous</a></li>
                        <?php else : ?>
                            <li><a href="#" onclick="prevPage('userPageIndex', 'frmUserGridView')">« Previous</a></li>
                        <?php endif; ?>
                        <?php foreach ($pagData->pagesInRange as $pageIndex) : ?>
                            <li <?php if ($pagData->current == $pageIndex) echo 'class="current"' ?>>
                                <a class="pageIndexValue" href="#"><?php echo $pageIndex ?></a>
                            </li>
                        <?php endforeach; ?>
                        <?php if ($paginator->getCurrentPageNumber() >= $paginator->count()) : ?>
                            <li><a>Next »</a></li>
                        <?php else : ?>
                            <li><a href="#" onclick="nextPage('userPageIndex', 'frmUserGridView', <?php echo $paginator->count() ?>)">Next »</a></li>
                        <?php endif; ?>
                    </ul>
                </div>
            </div>
            <div id="table">
                <table id="gridview">
                    <thead>
                        <tr class="columns">
                            <input type="hidden" name="userOrder[name]" value="<?php echo $sorter->getName() ?>" id="userOrder"/>
                            <input type="hidden" name="userOrder[direction]" value="<?php echo $sorter->getDirection() ?>" id="userOrderDirection"/>
                            <th></th>
                            <th class="columnFilter" id="user_id">ID</th>
                            <th>Avatar</th>
                            <th class="txtLeft columnFilter" id="user_first_name">First Name</th>
                            <th class="txtLeft columnFilter" id="user_last_name">Last Name</th>
                            <th class="txtLeft columnFilter" id="user_username">Username</th>
                            <th class="txtLeft columnFilter" id="user_is_active">Status</th>
                            <th>Action</th>
                        </tr>
                        <tr class="filters">
                            <td colspan="2" width="10%"></td>
                            <td width="10%"></td>
                            <td width="15%">
                                <input type="text" name="userFilter[first_name][value]" class="hardtv-input-style-2" value="<?php echo $filters->getValue('first_name'); ?>" style="width:98%"/>
                                <input type="hidden" name="userFilter[first_name][type]" value="string"/>
                            </td>
                            <td width="15%">
                                <input type="text" name="userFilter[last_name][value]" class="hardtv-input-style-2" value="<?php echo $filters->getValue('last_name'); ?>" style="width:98%"/>
                                <input type="hidden" name="userFilter[last_name][type]" value="string"/>
                            </td>
                            <td width="20%">
                                <input type="text" name="userFilter[username][value]" class="hardtv-input-style-2" value="<?php echo $filters->getValue('username'); ?>" style="width:98%"/>
                                <input type="hidden" name="userFilter[username][type]" value="string"/>
                            </td>
                            <td width="10%">
                            	<?php echo fx_control::newInstance('userFilter[is_active][value]')
										 ->createType('option')
										 ->addOption('Any Status', '')
										 ->addOption('Active', '1')
										 ->addOption('DeActive', '0')
										 ->addClass('stdSelect')
										 ->value($filters->getValue('is_active'))
										 ->render(); 
								?>
								<input type="hidden" name="userFilter[is_active][type]" value="equal"/>
                            </td>
                            <td width="15%">
                            	&nbsp;
                            </td>
                        </tr>
                    </thead>
                    <tbody>
                    <?php foreach ($collection as $user) : ?>
                        <tr id="row_<?php echo $user->getId() ?>" class="activeRow">
                            <input class="editUrl" type="hidden" value="<?php echo $user->getUserUrl(); ?>" />
                            <td class="select noActiveRow">
                                <?php echo fx_control::newInstance('user_checkbox[]')
												 ->createType('checkbox')
												 ->value($user->getId())
												 ->addClass('chkUser')
												 ->removeClass('inputText')
												 ->bindingCheckbox($user_ids_array)
												 ->render();
								?>
                            </td>
                            <td><?php echo $user->getId() ?></td>
                            <td>
                            	<img src="<?php echo $user->getAvatar() ?>" width="50px" /> 
                            </td>
                            <td>
                            	<?php echo $user->getFirstName() ?>
                           	</td>
                           	<td>
                            	<?php echo $user->getLastName() ?>
                           	</td>
                            <td>
                            	<?php echo $user->getUsername() ?>
                           	</td>
                            <td>
	                            <?php echo fx_control::newInstance('is_active')
	                                 ->createType('matchedText')
	                                 ->removeData('id')
	                                 ->removeClass('inputText')
	                                 ->addOption('Active', '1')
	                                 ->addOption('DeActive', '0')
	                                 ->value($user->getIsActive())
	                                 ->render();
	                            ?>
                            </td>
                            <td class="action noActiveRow">
                            	<a class="flashEditor" href="<?php echo site_url('admin/system/user/edit/id/' . $user->getId(), true) ?>"><span>Edit</span></a> &nbsp; | &nbsp;
                            	<a href="<?php echo site_url('admin/system/user/delete/id/' . $user->getId(), true) ?>" onclick="confirmDelete('User');"><span>Delete</span></a>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
            <div class="pagination">
                <div class="results">
                    <span>showing results <?php echo $pagData->firstItemNumber ?>-<?php echo $pagData->lastItemNumber ?> of <?php echo $found ?></span>
                </div>
                <div class="page">
                    <ul>
                        <?php if ($paginator->getCurrentPageNumber() <= 1) : ?>
                            <li><a>« Previous</a></li>
                        <?php else : ?>
                            <li><a href="#" onclick="prevPage('userPageIndex', 'frmUserGridView')">« Previous</a></li>
                        <?php endif; ?>
                        <?php foreach ($pagData->pagesInRange as $pageIndex) : ?>
                            <li <?php if ($pagData->current == $pageIndex) echo 'class="current"' ?>>
                                <a class="pageIndexValue" href="#"><?php echo $pageIndex ?></a>
                            </li>
                        <?php endforeach; ?>
                        <?php if ($paginator->getCurrentPageNumber() >= $paginator->count()) : ?>
                            <li><a>Next »</a></li>
                        <?php else : ?>
                            <li><a href="#" onclick="nextPage('userPageIndex', 'frmUserGridView', <?php echo $paginator->count() ?>)">Next »</a></li>
                        <?php endif; ?>
                    </ul>
                </div>
            </div>
        </div>
    </div>
<?php echo form_close(); ?>
<script language="javascript" type="text/javascript">
    jQuery("#gridview")
    .decorateTable()
    .lightHoverRow()
    .activePageIndex('pageIndexValue', 'userPageIndex', 'frmUserGridView')
    .activeSortableAbility("frmUserGridView", "columnFilter", "user_", "userOrder", "userOrderDirection")
    .checkboxCallbackHandler('chkUser', 'user_ids', 'userItemSelected', 'userSelectedValueHidden')
    .activeResetButton('frmUserGridView', 'btnReset', '<?php echo site_url('admin/system/user/index', true)?>')
    .activeColorBox('flashEditor');
</script>